package com.example.spzx.Service.impl;

import cn.hutool.db.PageResult;
import com.example.spzx.Mapper.BrandMapper;
import com.example.spzx.Service.BrandService;
import com.example.spzx.model.entity.product.Brand;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BrandServiceImpl implements BrandService {
    @Resource
    private BrandMapper brandMapper;
    public PageInfo<Brand> getlist(Integer pageNum, Integer pageSize){
        PageHelper.startPage(pageNum,pageSize);
        Page<Brand> list=brandMapper.getlist();
        PageInfo<Brand> pageResult=new PageInfo<>();
        pageResult.setTotal(list.getTotal());
        pageResult.setList(list.getResult());
        return pageResult;


    }
    public   void save(Brand brand){
        brandMapper.save(brand);
    }
    public   void update(Brand brand){
        brandMapper.update(brand);
    }
    public   void delete(Integer id){
        brandMapper.delete(id);
    }
    public List<Brand> getall(){
       List<Brand> list= brandMapper.getall();
   return list;
    }
}
